package com.aabte.auth.tracker.infrastructure.persistence;

import com.aabte.auth.tracker.model.Tracker;
import com.aabte.auth.tracker.model.TrackerId;
import com.aabte.auth.tracker.repository.TrackerRepository;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.UUID;

@Component
public class TrackerRepositoryHibernate implements TrackerRepository {

    @Resource
    private TrackerDAO trackerDAO;

    @Override
    public TrackerId nextTrackerId() {
        return new TrackerId(UUID.randomUUID().toString().replaceAll("-", ""));
    }

    @Override
    public void store(Tracker tracker) {
        trackerDAO.save(tracker);
    }
}
